﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Supermarket.Bll;

namespace Supermarket.Web.CashierPages
{
    public partial class Sales : System.Web.UI.Page
    {
        private string productId;
        private string productName;
        private string productPrice;
        private string measureCode;

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void ViewBuyProduct_PreRender(object sender, EventArgs e)
        {
            ucBuyProduct.ProductId = productId;
            ucBuyProduct.ProductName = productName;
            ucBuyProduct.ProductPrice = productPrice;
            ucBuyProduct.Code = measureCode;
        }

        protected void LinkButtonPay_Click(object sender, EventArgs e)
        {
            Response.Redirect("CheckOutSale.aspx");
        }

        protected void GridViewProducts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);            
            
            productId = GridViewProducts.DataKeys[row.RowIndex].Value.ToString();
            productName = GridViewProducts.Rows[row.RowIndex].Cells[0].Text;
            productPrice = GridViewProducts.Rows[row.RowIndex].Cells[1].Text;
            measureCode = GridViewProducts.Rows[row.RowIndex].Cells[2].Text;

            MultiViewSales.ActiveViewIndex = 1;
        }
    }
}